<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
    <head>
        <title>三七物联管理平台</title>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
         <link rel="stylesheet" type="text/css" href="/home/css/rude.css"/>
        <link href="/home/css/forget.css" type="text/css" rel="stylesheet">
        <link href="/home/css/global.css" type="text/css" rel="stylesheet">
        <style type="text/css">
          
          body{
               overflow: hidden;
               background: url(../images/reg_bg.png) no-repeat; 
              background-size: 100% 100%;  
              -moz-background-size: 100% 100%;  
              -webkit-background-size: 100% 100%; 
            }
            #pwd,#rpwd{
                width: 86%;
                height: 34px;
            }

        </style>
    </head>
    <body>
         <div style="position: relative;">
            <a href="#" onClick="javascript:history.back(-1);"><img src="/home/images/icon/re.png"  style="display: block; position: absolute;left: 2%;margin-top:3%;"></a>
       </div>  
        <div id="layout">
            <span>密码重置</span>
            <form  method="get" action="/home/login/index" onsubmit="return fn4()" >
                 {{csrf_field()}}
            <ul>
                <p id="err_msg"></p>
               <li><i class="pw"><img src="/home/images/pwd.png"></i><input class="pwd" type="password"  name="pwd" id="pwd" placeholder="请输入密码" /></li>
                <li><i class="pw2"><img src="/home/images/pwd.png"></i><input class="pwd2" type="password" name="pwd2" id="rpwd" placeholder="请再次输入密码" /></li>
            </ul>
                <div class="reg_btn">
                    <button class="submit" type="button" id="btn">完成</button>
                </div>
            </form>
        </div>
    </body>
    <script src="/home/js/jquery.js" type="text/javascript" charset="utf-8"></script>
    <script type="text/javascript">
   var err_msg = document.getElementById('err_msg'); 
   var pwd = document.getElementById('pwd'); 
   var rpwd = document.getElementById('rpwd'); 
        pwd.onfocus = function () {
    err_msg.innerHTML = "*由至少六位纯数字组成";
    } 
   function pwfn() {
    if(pwd.value == "") {
        err_msg.innerHTML = "*密码不能为空";
        return false;
    }else{
   var regex3 = /^\d{6,}$/;
    if(regex3.test(pwd.value) == true){
        return true;
     }else {
        err_msg.innerHTML = "*密码不对";
        return false;
     }
    }   
}
 
 pwd.onblur = pwfn;

 function rpwfn() {
    if(rpwd.value == "") {
        err_msg.innerHTML = "*确认密码不能为空";
        return false;
    }else{
      if(pwd.value == rpwd.value) {
      return true;
    } else {
        err_msg.innerHTML = "*两次密码输入不一致";
        return false;
    }
    }
   
}
rpwd.onblur = rpwfn;

     function fn4() {
       var res9= pwfn()  
       var res10= rpwfn()        
       return res9 &&  res10;
}
  $('#btn').on('click', function(){
          var res9= pwfn()  
          var res10= rpwfn()
       if ( res9 && res10) {
        $.ajax({
                type: 'POST',
                url: "/home/forget/change",
                data: $('form').serialize(),
                dataType: 'json',
                success: function(data){
                   if(data.status ==1){
                       //修改成功
                       alert('修改成功');
                    
                       window.location.href = "/home/login/index";
                   }
                   if(data.status==2){
                       //修改失败
                       alert('修改失败');
                   }
                }
            });
       
       }   
            
        })


    </script>
</html>